# frozen_string_literal: true

class SchemasController < ApplicationController
  def index
    render json: SchemaService.search(params)
  end

  def show
    render json: SchemaService.show(params.require(:id))
  end

  def create
    render json: SchemaService.create(
      params.require(:schema).permit!
    )
  end

  def update
    render json: SchemaService.update(params[:id], schema_params.permit(:name, :description, :status))
  end

  def destroy
    render json: SchemaService.delete(params.require(:id))
  end

  private

  def schema_params
    params.require(:schema)
  end
end
